//_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/.
// 			VisualNovelToolkit		     /_/_/_/_/_/_/_/_/_/.
// Copyright ©2013 - Sol-tribe.	/_/_/_/_/_/_/_/_/_/.
//_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/.

using UnityEngine;
using System.Collections;

[ ExecuteInEditMode ]
public class GUIInput : GUIBase {
//	public Texture2D m_AutoModeTex;
	public FlagTable varTable;
	public string varName = "username";

	private Rect m_Rect = new Rect( 0f , 0f , 200f , 44f);
	private Rect m_OkButtonRect = new Rect( 0f , 0f , 50f , 44f);

	//	private float m_FontSize = 30f;

	private string m_InputStr = "";

	void OnEnable(){
		ViNoAPI.EnableUpdateADV( false );
	}

	void OnDisable(){
		ViNoAPI.EnableUpdateADV( true );
		VM.Instance.ProgressProgramCounter( 1 );
	}

	public void Init( string varName , FlagTable flagTable , float left , float top , float size , float width , float height ){
		this.varTable = flagTable;
		this.varName = varName;
		
		m_Rect.x = left;
		m_Rect.y = top;
		m_Rect.width = width;
		m_Rect.height = height;
		
//		m_FontSize = size;

		m_OkButtonRect.x = left + width;
		m_OkButtonRect.y = top;
		m_OkButtonRect.width = 100f;
		m_OkButtonRect.height = height;
	}

	public override void OnGUICustom(){	
		m_InputStr = GUI.TextField( m_Rect , m_InputStr );

		// For Debugging.
		if( GUI.Button( m_OkButtonRect , "OK" ) ){//} , GUILayout.Width( 150f ) ) ){
			varTable.SetStringValue( varName , m_InputStr );				
//			PlayerPrefs.SetString( "PlayerName" , m_InputStr );
			Destroy( this.gameObject );			
		}
	}
	
}
